package chp12;

public class Tool2 {


    //对象数组
    public void show(Student[] students){
        //怎么显示各个学生信息
        for (int i = 0; i < students.length; i++) {
            System.out.println(students[i].name+" "+students[i].age);
        }
    }

    public static void main(String[] args) {
        Student[] students = new Student[3];

        students[0] = new Student();
        students[0].name = "jack";
        students[0].age = 22;
        students[1] = new Student();
        students[1].name = "tom";
        students[1].age = 23;
        students[2] = new Student();
        students[2].name = "rose";
        students[2].age = 24;

        //怎么初始化学生
//        Student student1 = new Student();
//        student1.name = "jack";
//        student1.age = 19;
//
//        Student student2 = new Student();
//        student2.name = "tom";
//        student2.age = 22;
//
//        Student student3 = new Student();
//        student3.name = "peter";
//        student3.age = 12;
//
//        students[0] = student1;
//        students[1] = student2;
//        students[2] = student3;

        Tool2 tool2 = new Tool2();
        tool2.show(students);
    }
}
